package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.model.PushMessage;
import com.ytjj.qmyx.admin.model.response.PushMessagePro;
import com.ytjj.qmyx.admin.service.PushMessageService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 * 消息列表
 */
@RestController
@AllArgsConstructor
@RequestMapping("/pushMessage")
public class PushMessageController {

    private PushMessageService pushMessageService;

    /**
     * 消息列表接口
     * @param pushMessagePro
     * @return
     */
    @PostMapping("/page")
    public CommonResult selectPushMessagePage(PushMessagePro pushMessagePro) {
        return CommonResult.success(pushMessageService.selectPushMessagePage(pushMessagePro));
    }

    /**
     * 消息列表下拉框
     * @param messageTypeId
     * @return
     */
    @GetMapping("/pushMessage")
    public CommonResult PushMessage(Integer messageTypeId) {
        return CommonResult.success(pushMessageService.PushMessage(messageTypeId));
    }

    /**
     * 消息详情
     * @param id
     * @return
     */
    @GetMapping("/selectPushMessage")
    public CommonResult selectPushMessage(Integer id) {
        return CommonResult.success(pushMessageService.selectPushMessage(id));
    }

    /**
     * 新增消息
     * @param pushMessage
     * @return
     */
    @PostMapping("/insertPushMessage")
    public CommonResult insertPushMessage(@RequestBody List<PushMessage> pushMessage) {
        return CommonResult.success(pushMessageService.insertPushMessage(pushMessage));
    }

    /**
     * 修改消息
     * @param pushMessage
     * @return
     */
    @PostMapping("/updatePushMessage")
    public CommonResult updatePushMessage(@RequestBody PushMessage pushMessage) {
        return CommonResult.success(pushMessageService.updatePushMessage(pushMessage));
    }
}
